// This is the master phoneme file.

//*******************************************************************
// Stress Phonemes
//*******************************************************************

phoneme %  //  Unstressed
  stress
  stress_type 1
endphoneme

phoneme %%   //  Diminished stress
  stress
  stress_type 0
endphoneme

phoneme \,   //  [,] Secondary stress
  stress
  stress_type 2
endphoneme

phoneme \,\,  //  [,,] Secondary stress
  stress
  stress_type 3
endphoneme

phoneme '   //  Primary stress
  stress
  stress_type 4
endphoneme

phoneme ''  //  Primary stress (priority)
  stress
  stress_type 5
endphoneme

phoneme '!  //  Primary stress (emphasized)
  stress
  stress_type 6
endphoneme

phoneme =   //  Place stress on previous vowel
  stress
  stress_type 2
endphoneme

phonemetable base1 base

// The base phoneme table contains the utility phonemes, the consonants,
// and a schwa.  The vowels are defined in the language specific phoneme
// tables, which can also redefine consonants if they wish.


//*******************************************************************
// UTILITY PHONEMES
//*******************************************************************

phoneme ||  //   End Word
  pause
  lengthmod 9  // no effect
endphoneme

phoneme _  //  Short pause
  pause
  starttype _ endtype _
  lengthmod 1
  length 25
endphoneme

phoneme _! //   Short pause, don't replace by linking
  pause
  starttype _ endtype _
  lengthmod 1
  nolink
  length 35
endphoneme

phoneme _|   //  Very short pause
  pause
  starttype _ endtype _
  lengthmod 5
  length 1
endphoneme

phoneme _:   //   Standard pause
  pause
  starttype _ endtype _
  lengthmod 1
  length 75
endphoneme

phoneme _::  //   Long pause
  pause
  starttype _ endtype _
  lengthmod 1
  length 150
endphoneme

phoneme _;_  //   clause pause
  pause
  starttype _ endtype _
  lengthmod 1
  length 200
endphoneme

phoneme  _^_  //  Change dictionary (followed by language-code in ascii
  pause
  starttype _ endtype _
  lengthmod 1
  length 10
endphoneme 

phoneme  _X1  //  a language specific action
  pause
  starttype _ endtype _
  lengthmod 1
  length 10
endphoneme 

phoneme ?  // glottal stp
  vls glt stp
  lengthmod 3   // ??
  nolink
  Vowelin  glstop
  Vowelout glstop
  WAV(ustop/null)
endphoneme


phoneme : //  lengthen previous vowel by "length"
  virtual
  length 70
endphoneme

phoneme - //  Indicates the previous phoneme is a syllabic consonant
  virtual
endphoneme


// Some default vowel definitions

phoneme @    //  Schwa, e.g. alph**a**
  vwl   starttype #@  endtype #@
  unstressed
  length 140
  FMT(vowel/@)
endphoneme


phoneme @-   //  very short schwa
  vwl starttype #@  endtype #@
  unstressed nsy

  ipa ə
  IF nextPhW(*) OR nextPhW(r) THEN
    ipa NULL   // @-* is used to make 'r'
  ENDIF
  length 50
  FMT(vowel/@-)
endphoneme


phoneme a // tr**a**p
  vwl starttype #a endtype #a
  length 180
  FMT(vowel/a)
endphoneme


phoneme e // German **eh**, French **é**
  vwl starttype #e endtype #e
  length 170
  FMT(vowel/e)
endphoneme


phoneme i
  vwl starttype #i endtype #i
  length 170
  IfNextVowelAppend(;)
  FMT(vowel/i)
endphoneme


phoneme o // German **oo**, French **o**
  vwl starttype #o endtype #o
  length 170
  FMT(vowel/oo)
endphoneme


phoneme u
  vwl starttype #u endtype #u
  length 170
  FMT(vowel/u)
endphoneme


// Syllablic consonants
//=====================

phoneme m-
  vwl starttype #@ endtype #@
  ipa mU+0329
  lengthmod 4
  length 170

  IF thisPh(isWordStart) THEN
    length 190
  ENDIF
  IF KlattSynth THEN
    FMT(klatt/m-syl)
  ENDIF
  FMT(m/m-syl)
endphoneme

phoneme n-
  vwl starttype #@ endtype #@
  ipa nU+0329
  lengthmod 4
  length 170

  IF thisPh(isWordStart) THEN
    length 190
  ENDIF
  IF KlattSynth THEN
    FMT(klatt/n-syl)
  ENDIF
  FMT(n/n-syl)
endphoneme

phoneme N-
  vwl starttype #e endtype #e
  ipa ŋU+0329
  lengthmod 4
  length 190
  FMT(nn/nn-syl)
endphoneme


//*******************************************************************
// Other sounds
//*******************************************************************

phoneme #X1  // click, use for indicating capital letters
  vls alv frc sib
  lengthmod 3
  WAV(ustop/percus10, 60)
endphoneme


//*******************************************************************
// VIRTUAL - referred to in vowels'   vwl  starttype and endtype
// These each apply to a class of vowels
//*******************************************************************

phoneme #@  virtual
endphoneme

phoneme #a  virtual
endphoneme

phoneme #e  virtual
endphoneme

phoneme #i  virtual
endphoneme

phoneme #o  virtual
endphoneme

phoneme #u  virtual
endphoneme


//*******************************************************************
// SONORANTS
//*******************************************************************


phoneme r-   // syllabic r
  vwl  starttype #@  endtype #@
  ipa rU+0329
  unstressed
  length 220
  FMT(vowelr/r-voc)
endphoneme

phoneme l-   // syllabic l
  vwl  starttype #@  endtype #@
  ipa lU+0329
  unstressed
  length 200
  FMT(vwl_hi/l-voc)
endphoneme


phoneme r // **r**ed (Omitted if not immediately followed by a vowel)
  liquid rhotic
  ipa ɹ
  lengthmod 7

  IF nextPh(isNotVowel) THEN
    ChangePhoneme(r/)
  ENDIF

  NextVowelStarts
    VowelStart(r/r@, -15)
    VowelStart(r/ra, -15)
    VowelStart(r/re, -15)
    VowelStart(r/ri, -15)
    VowelStart(r/ro, -15)
    VowelStart(r/ru, -15)
  EndSwitch

  IF prevPh(isVowel) THEN
    VowelEnding(r/xr, -50)
  ENDIF

  IF prevPh(isPause) THEN
    FMT(r/_r)
  ELIF prevPh(t) OR prevPh(p) OR prevPh(k) THEN
    FMT(r/tr)
  ENDIF

  FMT(r/r)
endphoneme



phoneme r/   // used for [r] when not preceding a vowel
  liquid rhotic
  lengthmod 2

  IF nextPh(n) THEN
    FMT(r3/r_n) addWav(r3/rx)
  ENDIF

  IF prevPh(t) OR prevPh(p) OR prevPh(k) THEN
    FMT(r/trr)
  ENDIF

  IF prevPh(isNotVowel) THEN
    FMT(r/rr)
  ENDIF

  FMT(r3/r_) addWav(r3/rx)
endphoneme



phoneme R
  liquid trl
  lengthmod 6
  ipa r
  IF nextPhW(R2) THEN
    ipa NULL
  ENDIF
  Vowelin  f1=0  f2=1600 -300 300  f3=-200 80
  Vowelout f1=2  f2=1600 -300 300  f3=-200 80 brk
  FMT(r3/r_trill2) addWav(r3/r_trill2.wav, 65)
endphoneme

phoneme R2   // this is [R] from Slovak/Czech
  liquid trl
  lengthmod 6
  ipa r
  Vowelin  f1=0  f2=1700 -300 300  f3=-300 80
  Vowelout f1=2  f2=1700 -300 300  f3=-300 80 brk
  FMT(r3/r_trill) addWav(r3/r_trill.wav, 50)
endphoneme

phoneme R3  // Afrikaans
  liquid trl
  lengthmod 6
  length 60
  ipa r
  Vowelin  f1=2  f2=2700 -300 -200  f3=-1300 80  
  Vowelout f1=2  f2=1700 -300 -200  f3=-1300 80

  // vowel modifier is the same as for [r]
  NextVowelStarts
    VowelStart(r/r@, -15)
    VowelStart(r/ra, -15)
    VowelStart(r/re, -15)
    VowelStart(r/ri, -15)
    VowelStart(r/ro, -15)
    VowelStart(r/ru, -15)
  EndSwitch

  IF prevPh(isVowel) THEN
    VowelEnding(r/xr, -50)
  ENDIF

  FMT(r3/r_trill) addWav(r3/r_trill3.wav)
endphoneme


phoneme r"     // uvular trill
  vcd uvl frc
  ipa ʀ
  lengthmod 6
  IF nextPh(isNotVowel) THEN
    FMT(r3/r_uvl) addWav(r3/r_uvl.wav, 50)
  ENDIF
  FMT(r3/r_uvl) addWav(r3/r_uvl.wav, 75)
endphoneme


procedure vowelstart_l
  NextVowelStarts
    VowelStart(l/l@)
    VowelStart(l/la)
    VowelStart(l/le)
    VowelStart(l/li, -10)
    VowelStart(l/lo)
    VowelStart(l/lu)
  EndSwitch
endprocedure

phoneme l
  liquid
  lengthmod 7

  IF nextPh(isNotVowel) THEN
    ChangePhoneme(l/)
  ENDIF

  IF nextPh(isNotVowel) THEN
    // in case the next phoneme is no longer a vowel, in pass=2
    PrevVowelEndings
      VowelEnding(l/L1_@L, -60)
      VowelEnding(l/L1_aL, -40)
      VowelEnding(l/L1_eL, -30)
      VowelEnding(l/L1_iL, -30)
      VowelEnding(l/L1_oL, -40)
      VowelEnding(l/L1_uL, -40)
    EndSwitch

    FMT(l/l_)
    RETURN
  ENDIF

  CALL vowelstart_l

  IF prevPh(#@) THEN
    VowelEnding(l/xl, -50)
  ELIF prevPh(isVowel) THEN
    VowelEnding(l/xl, -40)
  ENDIF

  IF prevPh(isPause) THEN
    FMT(l/_l)
  ENDIF

  IF prevPh(t) THEN
    FMT(l/tl)
  ENDIF

  IF prevPh(l/) THEN
    FMT(l/l_long)    // double l, make it longer
  ENDIF

  FMT(l/l)
endphoneme


phoneme l/    // used for [l] when not before a vowel
  liquid
  lengthmod 7

  IF nextPh(isVowel) THEN
    ChangePhoneme(l)
  ENDIF

  PrevVowelEndings
    VowelEnding(l/L1_@L, -60)
    VowelEnding(l/L1_aL, -40)
    VowelEnding(l/L1_eL, -30)
    VowelEnding(l/L1_iL, -30)
    VowelEnding(l/L1_oL, -40)
    VowelEnding(l/L1_uL, -40)
  EndSwitch

  // we need to replace these with new FMT sequeces for jl and wl
  IF prevPhW(j) THEN
    FMT(l/L1_eL)
  ENDIF
  IF prevPhW(w) THEN
    FMT(l/L1_eL)
  ENDIF

  FMT(l/l_)
endphoneme

phoneme l/2    // 'dark' [l] after a vowel
  liquid
  lengthmod 7

  IF nextPh(isVowel) THEN
    ChangePhoneme(l)
  ENDIF

  CALL vowelstart_l

  IF prevPhW(j) THEN
    FMT(l/L2_eL)
  ENDIF
  IF prevPhW(w) THEN
    FMT(l/L2_uL)
  ENDIF

  PrevVowelEndings
    VowelEnding(l/L2_@L, -60)
    VowelEnding(l/L2_aL, -50)
    VowelEnding(l/L2_eL, -40)
    VowelEnding(l/L2_iL, -30)
    VowelEnding(l/L2_oL, -50)
    VowelEnding(l/L2_uL, -40)
  EndSwitch
endphoneme


phoneme l/3    // Replacement for [l/]
  liquid
  lengthmod 7

  IF nextPh(isVowel) THEN
    ChangePhoneme(l)
  ENDIF

  PrevVowelEndings
    VowelEnding(l/l_@)
    VowelEnding(l/l_a)
    VowelEnding(l/l_e)
    VowelEnding(l/l_i)
    VowelEnding(l/l_o)
    VowelEnding(l/l_u, -20)
  EndSwitch

//  IF nextPh(isLiquid) THEN
//    FMT(l/_l)
//  ENDIF

  FMT(l/l_)
endphoneme



phoneme l^    // palatal l, e.g. Italian **g**li
  liquid
  ipa ʎ
  lengthmod 7
  Vowelout len=60 lenadd rate
  length 100

  NextVowelStarts
    VowelStart(l^/j2@)
    VowelStart(l^/j2a)
    VowelStart(l^/j2e)
    VowelStart(l^/j2i)
    VowelStart(l^/j2o)
    VowelStart(l^/j2u)
  EndSwitch

  IF prevPh(isPause) THEN
    FMT(l^/_l^)
  ENDIF

  FMT(l^/l^)
endphoneme


phoneme l.
  liquid rfx
  ipa ɭ
  lengthmod 7
  FMT(l^/l_rfx)
endphoneme


phoneme L/
  import_phoneme base1/l/2
endphoneme

phoneme L   // velar L
  liquid
  lengthmod 7

  IF nextPh(isNotVowel) THEN
    ChangePhoneme(L/)     // use 'dark' [l] after a vowel
  ENDIF

  VowelEnding(ll/xll, -40)

  IF prevPh(isPause) THEN
     FMT(ll/_ll)
  ENDIF

  FMT(ll/ll)
endphoneme




phoneme w
  liquid
  lengthmod 7
  starttype #u
  
  IF nextPh(isVowel) THEN
    NextVowelStarts
      VowelStart(w/w@)
      VowelStart(w/wa)
      VowelStart(w/we)
      VowelStart(w/wi)
      VowelStart(w/wo)
      VowelStart(w/wu)
    EndSwitch

    VowelEnding(w/xw, -30)

    IF prevPhW(isNasal) THEN
      FMT(w/w)
    ELSEIF prevPhW(h) THEN
      // none,  [hw]
    ELSE
      FMT(w/_w)
    ENDIF
  ELSE
    // no vowel follows
    Vowelout len=50
    IF prevPh(#i) THEN
      FMT(w/iw_)
    ENDIF
    FMT(w/w_)
  ENDIF
endphoneme




phoneme j // **y**es
  liquid pal starttype #i
  lengthmod 7

  IF nextPhW(isVowel) THEN
    NextVowelStarts
      VowelStart(j/j@)
      VowelStart(j/ja)
      VowelStart(j/je)
      VowelStart(j/ji)
      VowelStart(j/jo)
      VowelStart(j/ju)
    EndSwitch

    VowelEnding(j/xj, -30)

    IF prevPh(isPause) THEN
      FMT(j/_j)
    ENDIF
  ELSE
    // no vowel follows
    Vowelout len=70
    FMT(j/j_)
  ENDIF
endphoneme


phoneme ;     // linking j, used between (i) vowels and a following vowel
              // also to palatalize consonants
  liquid pzd
  lengthmod 0

  IF prevPh(#i) THEN
    ipa NULL   // linking after i vowel, don't show in ipa
  ENDIF

  IF nextPh(isNotVowel) THEN
    ChangePhoneme(NULL)   // this is to ignore this phoneme if not before a vowel
  ENDIF

  NextVowelStarts
    VowelStart(j2/j2@)
    VowelStart(j2/j2a)
    VowelStart(j2/j2e)
    VowelStart(j2/j2i)
    VowelStart(j2/j2o)
    VowelStart(j2/j2u)
  EndSwitch

  IF prevPh(#i) THEN
    VowelEnding(j2/xj2, -40)
  ENDIF

  IF prevPh(isPause) THEN
    FMT(j2/_j2)
  ENDIF
endphoneme


//*******************************************************************
// NASAL CONSONANTS
//*******************************************************************


phoneme m
  vcd blb nas
  Vowelout f1=2  f2=1000 -500 -350  f3=-200 80 brk
  lengthmod 4

  IF KlattSynth THEN
    Vowelin  f1=0  f2=1000 -50 -200  f3=-200 80
    IF nextPh(isPause2) THEN
      FMT(klatt/m_)
    ENDIF
    FMT(klatt/m)
  ENDIF

  NextVowelStarts
    VowelStart(m/m@)
    VowelStart(m/ma)
    VowelStart(m/me)
    VowelStart(m/mi)
    VowelStart(m/mo)
    VowelStart(m/mu)
  EndSwitch

  IF prevPh(isNotVowel) AND nextPhW(isLiquid) THEN
    FMT(m/mj)
  ELIF prevPh(isPause) THEN
    FMT(m/_m)
  ELIF nextPh(isNotVowel) THEN
    FMT(m/m_)
  ENDIF
endphoneme


phoneme n
  vcd alv nas
  Vowelout f1=2 f2=1500 -300 250  f3=-100 80  rms=20 brk
  lengthmod 4

  IF KlattSynth THEN
    Vowelin f1=0 f2=1500 -200 200 f3=0 80
    FMT(klatt/n)
  ENDIF

  NextVowelStarts
    VowelStart(n/n@)
    VowelStart(n/na)
    VowelStart(n/ne)
    VowelStart(n/ni)
    VowelStart(n/no)
    VowelStart(n/nu)
  EndSwitch

  IF prevPh(isNotVowel) AND nextPhW(isLiquid) THEN
    FMT(n/nj)
  ELIF prevPh(isPause) OR prevPh(n) THEN
    FMT(n/_n)
  ELIF nextPh(isNotVowel) THEN
    FMT(n/n_)
  ENDIF
endphoneme


phoneme n.
  vcd rfx nas
  ipa ɳ
  starttype n  endtype n
  Vowelin f1=2 f2=1700 -300 300  f3=-500 80  rms=20 colr=2
  Vowelout f1=2 f2=1700 -300 300  f3=-500 80  rms=20 brk colr=2
  lengthmod 4

  IF KlattSynth THEN
    FMT(klatt/nr)
  ENDIF

  NextVowelStarts
    VowelStart(n/nr@)
    VowelStart(n/nra)
    VowelStart(n/nre)
    VowelStart(n/nri)
    VowelStart(n/nro)
    VowelStart(n/nru)
  EndSwitch

  IF prevPh(isNotVowel) AND nextPhW(isLiquid) THEN
    FMT(n/nj)
  ELIF prevPh(isPause) OR prevPh(n.) THEN
    FMT(n/_nr)
  ELIF nextPh(isNotVowel) THEN
    FMT(n/nr_)
  ENDIF
endphoneme


phoneme n^ // Spanish **ñ**
  vcd pal nas pzd
  ipa ɲ
  Vowelout f1=3 f2=2500 300 500  f3=100 80  len=45 brk rate
  lengthmod 4

  IF KlattSynth THEN
    VowelStart(klatt/n^@)
    FMT(klatt/n^)
  ENDIF

  NextVowelStarts
    VowelStart(n^/n^@)
    VowelStart(n^/n^a)
    VowelStart(n^/n^e)
    VowelStart(n^/n^i)
    VowelStart(n^/n^o)
    VowelStart(n^/n^u)
  EndSwitch

  IF prevPh(isPause) THEN
    FMT(n^/_n^)
  ELIF nextPh(isNotVowel) THEN
    IF nextPhW(n^) THEN
      length 75
    ELIF prevPhW(n^) THEN
      length 100
    ENDIF
    FMT(n^/n^_)
  ENDIF
endphoneme


phoneme N // si**ng** 
  vcd vel nas
  Vowelout f1=3 f2=2300 300 400  f3=-200 80  len=40 rms=20 brk
  lengthmod 8            // longer than 'n'

  IF KlattSynth THEN
    Vowelin f1=0 f2=2100 50 300 f3=0 80
    IF nextPh(isPause2) THEN
      FMT(klatt/nn_)
    ENDIF
    FMT(klatt/nn)
  ENDIF

  NextVowelStarts
    VowelStart(nn/nn@)
    VowelStart(nn/nna)
    VowelStart(nn/nne)
    VowelStart(nn/nni)
    VowelStart(nn/nno)
    VowelStart(nn/nnu)
  EndSwitch

  IF prevPh(#i) THEN
    VowelEnding(nn/inn, -40)
  ENDIF

  IF prevPh(isNotVowel) AND nextPhW(isLiquid) THEN
    FMT(nn/nnj)
  ELIF prevPh(isPause) THEN
    FMT(nn/_nn)
  ELIF nextPh(isNotVowel) THEN
    FMT(nn/nn_)
  ENDIF
endphoneme


phoneme **    //   TEST flap
  liquid alv rhotic
  ipa ɾ
  lengthmod 3
  Vowelout f1=3 f2=1600 -300 300  f3=-300 80 rms=35 len=15
  Vowelin f1=2  f2=1600 -300 300  f3=-100 80 len=20

  IF prevPh(#i) OR prevPh(#e) THEN
    FMT(r3/@tap2)
  ENDIF
  FMT(r3/@tap)
endphoneme



phoneme *    //   flap
  vcd alv flp rhotic
  brkafter
  ipa ɾ
  lengthmod 3

  IF prevPhW(@-) THEN
    ipa r   // @-*  sequence for [r]
  ENDIF

  IF nextPh(#e) OR nextPh(#i) THEN
    Vowelin f1=0  f2=1500 -300 300  f3=-200 80
    FMT(d/tap1) addWav(r3/rx, 150)
    FMT(d/tap1) addWav(r3/rx, 150)
  ENDIF

  Vowelin f1=2  f2=1500 -300 300  f3=-200 80
  IF nextPh(#a) THEN
    FMT(d/tap3) addWav(r3/rx, 200)
  ENDIF

  IF nextPh(r) THEN
    FMT(d/dr)
  ENDIF

  Vowelout f1=3 f2=1500 -400 300  f3=-200 80 rms=35 len=50
  Vowelin f1=0  f2=1500 -300 300  f3=-200 80
  FMT(d/tap3) addWav(r3/rx, 200)
endphoneme



phoneme r.    //   retroflex
  liquid rfx
  lengthmod 3
  Vowelout f1=3 f2=1400 -400 300  f3=-400 80 rms=35 len=15 colr=2
  Vowelin f1=2  f2=1400 -400 300  f3=-400 80 len=20
  
  IF nextPh(isNotVowel) THEN
    FMT(r3/@tap_rfx_)
  ENDIF
  FMT(r3/@tap_rfx)
endphoneme


//*******************************************************************
// VOICED STOPS
//*******************************************************************


phoneme b
  vcd blb stp
  voicingswitch p 
  Vowelout f1=2  f2=1000 -500 -300  f3=-300 80 brk
  lengthmod 5

  IF PreVoicing THEN
    FMT(b/xb)
  ENDIF

  IF KlattSynth THEN
    Vowelin f1=1  f2=1000 -500 -300  f3=-300 80
    IF nextPh(isPause2) THEN
      FMT(klatt/b)  addWav(x/b_)
    ENDIF
    FMT(klatt/b) addWav(x/b)
  ENDIF

  IF nextPh(isPause2) THEN
    FMT(b/b_) addWav(x/b_)
  ELIF nextPh(@-) THEN
    FMT(b/b@2) addWav(x/b)
  ELIF nextPh(#@) THEN
    FMT(b/b@) addWav(x/b)
  ELIF nextPh(#a) THEN
    FMT(b/ba) addWav(x/b)
  ELIF nextPh(#e) THEN
    FMT(b/be) addWav(x/b)
  ELIF nextPh(#i) THEN
    FMT(b/bi) addWav(x/b)
  ELIF nextPh(#o) THEN
    FMT(b/bo) addWav(x/b)
  ELIF nextPh(#u) THEN
    FMT(b/bu) addWav(x/b)
  ENDIF

  FMT(b/b) addWav(x/b)
endphoneme


phoneme d
  vcd alv stp
  voicingswitch t
  lengthmod 5
  Vowelin f1=1  f2=1700 -300 300  f3=-100 80
  Vowelout f1=2 f2=1700 -300 300  f3=-100 80 brk

  IF PreVoicing THEN
    FMT(d/xd)
  ENDIF

  IF nextPh(isPause2) THEN
    FMT(d/d_)  addWav(x/d_)
//  ELIF nextPh(r) THEN
//    FMT(d/dr) addWav(x/d)
  ENDIF

  FMT(d/d) addWav(x/d)
endphoneme


phoneme d[
  vcd dnt stp
  voicingswitch t[
  lengthmod 5
  Vowelin f1=2  f2=1500 -300 300  f3=-150 80
  Vowelout f1=2 f2=1500 -300 300  f3=-150 80

  IF PreVoicing THEN
    FMT(d/xd)
  ENDIF

  IF nextPh(isPause2) THEN
    FMT(d/d_)  addWav(x/d_)
  ELIF nextPh(r) THEN
    FMT(d/dr) addWav(x/d_dnt, 100)
  ENDIF

  FMT(d/d) addWav(x/d_dnt, 100)
endphoneme


phoneme dZ // **j**udge
  vcd pla afr sib
  voicingswitch tS
  lengthmod 5
  Vowelin f1=2  f2=2300 200 400  f3=100 80
  Vowelout f1=2  f2=2300 250 300  f3=100 80 brk

  IF PreVoicing THEN
    FMT(dzh/xdzh)
  ENDIF

  IF nextPh(isPause2) THEN
    FMT(dzh/dzh_) addWav(x/dzh_)
  ENDIF
  FMT(dzh/dzh) addWav(x/dzh)
endphoneme


phoneme dZ;
  vcd alp sib afr
  voicingswitch tS;
  ipa dʑ
  lengthmod 5
  Vowelin f1=2  f2=2700 400 600  f3=300 80 rate len=70
  Vowelout f1=2 f2=2700 400 600  f3=300 80

  IF PreVoicing THEN
    FMT(dzh/xdzh)
  ENDIF

  IF KlattSynth THEN
    IF nextPh(isPause2) THEN
      FMT(dzh/dzh_) addWav(x/dzh_)
    ENDIF
    FMT(dzh/dzh) addWav(x/dz_pzd)
  ENDIF

  IF nextPh(isPause2) THEN
    FMT(dzh/dzh_) addWav(x/dzh_)
  ENDIF
  FMT(dzh/dzh) addWav(x/dz_pzd)
endphoneme


phoneme J
  vcd pal afr sib pzd
  voicingswitch c
  lengthmod 5
  Vowelin f1=2  f2=2700 400 600  f3=300 80 rate len=70
  Vowelout f1=2 f2=2700 400 600  f3=300 80 colr=1

  IF PreVoicing THEN
    FMT(dzh/xdz_pzd)
  ENDIF

  IF KlattSynth THEN
    IF nextPh(isPause2) THEN
      FMT(klatt/dz_pzd_) addWav(x/dzh, 35)
    ENDIF
    FMT(klatt/dz_pzd) addWav(x/dzh, 45)
  ENDIF

  IF nextPh(isPause2) THEN
    FMT(dzh/dz_pzd_) addWav(x/dzh, 35)
  ENDIF
  FMT(dzh/dz_pzd) addWav(x/dzh, 45)
endphoneme


phoneme g
  vcd vel stp
  voicingswitch k
  lengthmod 5
  Vowelin f1=2  f2=2300 200 300  f3=-300 80
  Vowelout f1=2  f2=2300 250 300  f3=-300 80 brk

  IF PreVoicing THEN
    FMT(g/xg)
  ENDIF

  IF nextPh(isPause2) THEN
    FMT(g/g_) addWav(x/g_)
  ENDIF
  FMT(g/g) addWav(x/g2, 150)
endphoneme



//*******************************************************************
// VOICED fricatives
//*******************************************************************


phoneme B
  vcd blb frc
  voicingswitch f
  lengthmod 6
  Vowelin  f1=2  f2=1000 -300 -200  f3=-100 100
  Vowelout f1=2  f2=1000 -500 -300  f3=-100 60  len=50

  IF KlattSynth THEN
    IF nextPh(isPause2) THEN
      FMT(klatt/v_) addWav(vocw/v)
    ENDIF
    FMT(klatt/bh) addWav(vocw/v)
  ENDIF

  IF nextPh(isPause2) THEN
    FMT(voc/v_) addWav(vocw/v)
  ENDIF
  FMT(voc/bh) addWav(vocw/v)
endphoneme


phoneme v
  vcd lbd frc
  voicingswitch f
  lengthmod 6
  Vowelin  f1=0  f2=1000 -300 -200  f3=-300 100
  Vowelout f1=0  f2=1000 -500 -300  f3=-300 60  len=50

  IF KlattSynth THEN
    Vowelout f1=1  f2=1000 -500 -300  f3=-300 60  len=50 brk
    IF nextPh(isPause2) THEN
      FMT(klatt/v_) addWav(vocw/v)
    ENDIF
    FMT(klatt/v) addWav(vocw/v, 150)
  ENDIF

  IF nextPh(isPause2) THEN
    FMT(voc/v_) addWav(vocw/v)
  ENDIF
  IF thisPh(isWordStart) AND nextPhW(isLiquid) THEN
    length 70
  ENDIF
  FMT(voc/v) addWav(vocw/v)
endphoneme


phoneme v#        // approximant, not fricative
  vcd lbd frc
  ipa ʋ
  lengthmod 6
  voicingswitch f
  Vowelin  f1=0  f2=1000 -300 -200  f3=-300 100
  Vowelout f1=0  f2=1000 -500 -300  f3=-300 60  len=50
  IF nextPh(isPause2) THEN
    FMT(voc/v#_)
  ENDIF
  FMT(voc/v#)
endphoneme


phoneme D // **th**is
  vcd dnt frc
  voicingswitch T
  lengthmod 6
  Vowelout f1=0  f2=1700 -300 300  f3=-100 60  len=50

  IF KlattSynth THEN
    Vowelin f1=0 f2=1290 -300 300 f3=0 0
  ENDIF

  IF nextPh(isPause2) THEN
    FMT(voc/dh_) addWav(vocw/dh)
  ENDIF
  FMT(voc/dh) addWav(vocw/dh)
endphoneme


phoneme z
  vcd alv frc sib
  voicingswitch s
  lengthmod 6
  Vowelout f1=0  f2=1700 -300 300  f3=-100 60  len=50

  IF KlattSynth THEN
    Vowelin f1=0 f2=1390 -300 300 f3=0 0
    Vowelout f1=1  f2=1390 -300 300  f3=-100 60  len=50 brk
  ENDIF

  IF nextPh(isPause2) THEN
    FMT(voc/z_) addWav(ufric/s_, 70)
  ENDIF
  FMT(voc/z) addWav(ufric/s_, 85)
endphoneme


phoneme Z // plea**s**ure
  vcd pla frc sib
  voicingswitch S
  lengthmod 6
  Vowelin  f1=0  f2=2000 0 300  f3=-200 80
  Vowelout f1=2  f2=2000 0 300  f3=-200 80 brk

  IF KlattSynth THEN
    IF nextPh(isPause2) THEN
      FMT(klatt/zh_, 60) addWav(vocw/zh, 70)
    ENDIF
    FMT(klatt/zh) addWav(vocw/zh, 130)
  ENDIF

  IF nextPh(isPause2) THEN
    FMT(voc/zh_, 60) addWav(vocw/zh, 70)
  ENDIF
  FMT(voc/zh) addWav(vocw/zh, 130)
endphoneme


phoneme z.
  vcd pla frc sib
  ipa ʐ
  voicingswitch s.
  lengthmod 6
  Vowelin  f1=0  f2=1800 -100 300  f3=-300 80
  Vowelout f1=2  f2=1800 -100 300  f3=-300 80 brk

  IF KlattSynth THEN
    IF nextPh(isPause2) THEN
      FMT(klatt/zh_) addWav(vocw/zh_rfx)
    ENDIF
    FMT(klatt/zh) addWav(vocw/zh_rfx)
  ENDIF

  IF nextPh(isPause2) THEN
    FMT(voc/zh_) addWav(vocw/zh_rfx)
  ENDIF
  FMT(voc/zh) addWav(vocw/zh_rfx)
endphoneme


phoneme z;
  vcd alp sib frc
  ipa ʑ
  voicingswitch s;
  lengthmod 6
  Vowelin  f1=2  f2=2700 400 600  f3=300 80 rate len=70
  Vowelout f1=2  f2=2300 250 300  f3=-300 80 brk

  IF nextPh(isPause2) THEN
    FMT(voc/z_pzd_) addWav(ufric/s_pzd_, 80)
  ENDIF
  FMT(voc/z_pzd) addWav(ufric/s_pzd, 80)
endphoneme


phoneme Z;
  vcd alp sib frc
  voicingswitch S;
  ipa ʑ
  lengthmod 6
  Vowelin  f1=2  f2=2700 400 600  f3=300 80 rate len=70
  Vowelout f1=2  f2=2300 250 300  f3=-300 80 brk

  IF nextPh(isPause2) THEN
    FMT(voc/z_pzd_) addWav(ufric/sh_pzd_)
  ENDIF
  FMT(voc/z_pzd) addWav(ufric/sh_pzd, 80)
endphoneme


phoneme J^   // palatal fricative (Kirshenbaum C<vcd>)
  vcd pal frc pzd
  ipa ʝ
  voicingswitch C
  lengthmod 6
  Vowelin f1=1  f2=2700 400 600  f3=200 70
  Vowelout f1=1 f2=2700 400 600  f3=200 70 len=100

  FMT(voc/j) addWav(ufric/ch, 25)
endphoneme


phoneme Q
  vcd vel frc
  voicingswitch x
  lengthmod 6
  Vowelin f1=2  f2=2300 200 400  f3=-100 80
  Vowelout f1=2  f2=2300 250 300  f3=-300 80 brk

  IF KlattSynth THEN
    IF nextPh(isPause2) THEN
      FMT(klatt/qqh_) addWav(vocw/Q_)
    ENDIF
    FMT(klatt/qqh) addWav(vocw/Q)
  ENDIF

  IF nextPh(isPause2) THEN
    FMT(voc/Q_) addWav(vocw/Q_)
  ENDIF
  FMT(voc/Q) addWav(vocw/Q)
endphoneme


phoneme Q^
  vcd vel frc
  lengthmod 6
  Vowelin f1=2  f2=2700 400 600  f3=200 80
  Vowelout f1=2  f2=2700 40 600  f3=200 80 brk

  IF nextPh(isPause2) THEN
    FMT(voc/Q_) addWav(vocw/Q_)
  ENDIF
  FMT(voc/Q) addWav(vocw/Q)
endphoneme


phoneme Q"
  vcd uvl frc
  ipa ʁ
  lengthmod 6

  IF nextPh(isPause2) THEN
    FMT(voc/Q_ulv) addWav(ufric/xx, 60)
  ENDIF
  FMT(voc/Q_ulv) addWav(ufric/xx, 80)
endphoneme




//*******************************************************************
// UNVOICED STOPS
//*******************************************************************


phoneme p
  vls blb stp
  voicingswitch b
  lengthmod 2
  Vowelin  f1=0  f2=1000 -50 -100  f3=-200 80 amp=11
  Vowelout f1=0  f2=1000 -500 -350  f3=-300 80 rms=22

  IF nextPh(isPause2) THEN
    WAV(ustop/p_)
  ELIF nextPh(r) THEN
    WAV(ustop/pr, 70)
  ELIF nextPh(R) OR nextPh(R2) THEN
    WAV(ustop/pr)
  ELIF nextPh(@-) THEN
    WAV(ustop/p_unasp)
  ELIF nextPh(l) THEN
    WAV(ustop/pl)
  ENDIF
  WAV(ustop/p)
endphoneme


phoneme t
  vls alv stp
  voicingswitch d
  lengthmod 2
  Vowelin f1=0  f2=1700 -300 300  f3=-100 80
  Vowelout f1=0 f2=1700 -300 250  f3=-100 80  rms=20

  IF nextPh(isPause2) THEN
    WAV(ustop/t_)
  ELIF nextPh(r) OR nextPh(R) OR nextPh(R2) THEN
    WAV(ustop/tr)
  ELIF nextPh(@-) THEN
    WAV(ustop/t_dnt, 50)
  ENDIF
  WAV(ustop/t, 90)
endphoneme


phoneme t[        // dental variant of /t/
  vls dnt stp
  voicingswitch d[
  lengthmod 2
  Vowelin f1=1  f2=1500 -250 250  f3=-100 80  amp=16
  Vowelout f1=0 f2=1500 -300 250  f3=-100 80  rms=20

  IF nextPh(isPause2) THEN
    WAV(ustop/t_dnt, 35)
  ENDIF
  WAV(ustop/t_hi, 70)
endphoneme


phoneme tS     // **ch**urch
  vls pla afr sib
  voicingswitch dZ
  lengthmod 2
  Vowelin f1=0  f2=2300 200 400  f3=-100 80

  IF nextPh(isPause2) THEN
    WAV(ustop/tsh_)
  ENDIF
  WAV(ustop/tsh)
endphoneme


phoneme tS;
  vls alp sib afr
  voicingswitch dZ;
  ipa tɕ
  lengthmod 2
  Vowelin f1=0  f2=2700 400 600  f3=300 80 rate len=70

  IF nextPh(isPause2) THEN
    WAV(ustop/ts_pzd)
  ENDIF
  WAV(ustop/ts_pzd)
endphoneme


phoneme c
  vls pal stp pzd
  voicingswitch J
  lengthmod 2
  Vowelin f1=0  f2=2700 400 600  f3=300 80 rate len=70
  Vowelout f1=1  f2=2700 400 600  f3=200 70 len=50 colr=1

  IF nextPh(isPause2) THEN
    WAV(ustop/t_pzd, 30)
  ENDIF
  WAV(ustop/c, 150)
endphoneme


phoneme k
  vls vel stp
  voicingswitch g
  lengthmod 2
  Vowelin f1=0  f2=2300 200 300  f3=-200 80
  Vowelout f1=0 f2=2300 300 400  f3=-200 80  rms=20

  IF KlattSynth THEN
    Vowelout f1=0 f2=2300 200 300  f3=-200 80  rms=20
  ENDIF

  IF nextPh(isPause2) THEN
    WAV(ustop/k_)
  ELIF nextPh(r) OR nextPh(R) OR nextPh(R2) THEN
    WAV(ustop/kr)
  ELIF nextPh(#i) OR nextPh(;) THEN
    WAV(ustop/ki)
  ELIF nextPh(l) THEN
    WAV(ustop/kl)
  ELIF nextPh(@-) THEN
    WAV(ustop/k_unasp, 70)
  ENDIF
  WAV(ustop/k)
endphoneme


phoneme q
  vls uvl stp
  lengthmod 2
  Vowelin f1=1  f2=1700 0 200  f3=-300 80 gpaus f4 rms=30
  Vowelout f1=1 f2=1700 -100 200  f3=-300 80  f4 rms=35

  IF nextPh(isPause2) THEN
    WAV(ustop/q, 40)
  ELIF nextPh(#u) THEN
    WAV(ustop/q_u, 80)
  ENDIF
  WAV(ustop/q, 48)
endphoneme



//*******************************************************************
// UNVOICED fricatives
//*******************************************************************

phoneme f
  vls lbd frc
  voicingswitch v
  lengthmod 3
  Vowelout f1=0  f2=1000 -500 -350  f3=-200 80

  IF nextPh(isPause) THEN
    WAV(ufric/f_)
  ENDIF
  WAV(ufric/f)
endphoneme


phoneme T   // **th**in
  vls dnt frc
  voicingswitch D
  lengthmod 3
  Vowelin f1=0  f2=1700 -300 300  f3=-100 80
  Vowelout f1=0 f2=1700 -300 250  f3=-100 80  rms=20

  IF nextPh(isPause) THEN
    WAV(ufric/th_)
  ENDIF
  WAV(ufric/th)
endphoneme


phoneme s
  vls alv frc sib
  voicingswitch z
  lengthmod 3
  Vowelin  f1=0  f2=1700 -300 300  f3=-100 80
  Vowelout f1=0  f2=1700 -300 250  f3=-100 80  rms=20

  IF nextPh(isPause) THEN
    WAV(ufric/s_)
  ELIF nextPh(p) OR nextPh(t) OR nextPh(k) THEN
    WAV(ufric/s!)
  ENDIF
  WAV(ufric/s)
endphoneme


phoneme S // **sh**op
  vls pla frc sib
  voicingswitch Z
  lengthmod 3
  Vowelin  f1=0  f2=2100 100 300  f3=-100 80
  Vowelout f1=0  f2=2100 100 300  f3=-100 80

  IF nextPh(isPause) THEN
    WAV(ufric/sh_)
  ENDIF
  WAV(ufric/sh)
endphoneme


phoneme s.
  vls pla frc sib
  ipa ʂ
  voicingswitch z.
  lengthmod 3
  Vowelin  f1=0  f2=1800 -100 300  f3=-300 80
  Vowelout f1=0  f2=1800 -100 300  f3=-300 80

  IF nextPh(isPause) THEN
    WAV(ufric/sh_rfx, 60)
  ENDIF
  WAV(ufric/sh_rfx, 90)
endphoneme


phoneme s;
  vls pal frc sib pzd
  ipa ʂ
  voicingswitch z;
  lengthmod 3
  Vowelin  f1=1  f2=2700 400 600  f3=200 70 rate len=70
  Vowelout f1=1  f2=2700 400 600  f3=200 70 rate len=70

  IF nextPh(isPause) THEN
    WAV(ufric/s_pzd_)
  ENDIF
  WAV(ufric/s_pzd)
endphoneme


phoneme S;
  vls alp sib frc
  voicingswitch Z;
  ipa ɕ
  lengthmod 3
  Vowelin  f1=1  f2=2700 400 600  f3=200 70 rate len=70
  Vowelout f1=1  f2=2700 400 600  f3=200 70 rate

  IF nextPh(isPause) THEN
    WAV(ufric/sh_pzd_)
  ENDIF
  WAV(ufric/sh_pzd)
endphoneme


phoneme l#   // Lateral fricative (eg. Welsh "ll")
  vls alv frc
  ipa ɬ
  lengthmod 3

  NextVowelStarts
    VowelStart(l/l@)
    VowelStart(l/la)
    VowelStart(l/le)
    VowelStart(l/li, -10)
    VowelStart(l/lo)
    VowelStart(l/lu)
  EndSwitch

  IF prevPh(isVowel) THEN
    VowelEnding(l/xl, -40)
  ENDIF

  WAV(ufric/l#, 60)
endphoneme


phoneme C // German i**ch**
  vls pal frc
  lengthmod 3
  Vowelin f1=0  f2=2700 400 600  f3=200 70
  Vowelout f1=0 f2=2700 400 600  f3=200 70  rms=20

  IF nextPh(isPause) THEN
    WAV(ufric/ch_)
  ENDIF
  WAV(ufric/ch)
endphoneme


phoneme x // German bu**ch**
  vls vel frc
  voicingswitch Q
  lengthmod 3
  Vowelin f1=0  f2=2300 200 400  f3=-100 80
  Vowelout f1=0 f2=2300 300 400  f3=-100 80  rms=20

  IF nextPh(isPause) THEN
    WAV(ufric/x_, 60)
  ENDIF
  WAV(ufric/x_hr, 20)
endphoneme


phoneme X
  vls uvl frc
  voicingswitch Q"
  lengthmod 3

  IF nextPh(isPause) THEN
    WAV(ufric/xx, 70)
  ENDIF
  WAV(ufric/xx,80)
endphoneme


phoneme h
  vls glt apr
  lengthmod 3
  ipa h

  IF nextPh(#@) THEN
    WAV(h/h@)
  ELIF nextPh(#a) THEN
    WAV(h/ha)
  ELIF nextPh(#e) THEN
    WAV(h/he)
  ELIF nextPh(#i) THEN
    WAV(h/hi)
  ELIF nextPh(#o) THEN
    WAV(h/ho)
  ELIF nextPh(#u) THEN
    WAV(h/hu)
  ENDIF
  WAV(h/h_, 70)  // no vowel following
endphoneme



//*******************************************************************
// ADDITIONAL PHONEME TABLES
//*******************************************************************

phonemetable ja base1
include ph_japanese

phonemetable consonants base1
include ph_consonants


phonemetable base2 base1
include ph_base2

phonemetable en base1
include ph_english

phonemetable en-n en
include ph_english_n

phonemetable en-us en
include ph_english_us

phonemetable en-sc en
include ph_english_sc

phonemetable en-rp en
include ph_english_rp

phonemetable en-wm en
include ph_english_wm

phonemetable en-wi en
include ph_english_wi


phonemetable af base1
include ph_afrikaans

phonemetable cy base1
include ph_welsh

phonemetable ga base1
include ph_irish

phonemetable de base1
include ph_german

phonemetable eo base1
include ph_esperanto

phonemetable ia eo
include ph_interlingua

phonemetable jbo eo
include ph_lojban

phonemetable nci base2
include ph_nahuatl

phonemetable fi base1
include ph_finnish

phonemetable et base1
include ph_estonian

phonemetable fr base1
include ph_french

phonemetable hak base1
include ph_hakka

phonemetable nl base1
include ph_dutch


phonemetable hi_base base1
include ph_hindi_base

phonemetable hi hi_base
include ph_hindi

phonemetable bn hi_base
include ph_bengali

phonemetable ne hi_base
include ph_nepali

phonemetable ur hi_base
include ph_urdu

phonemetable pa hi_base
include ph_punjabi

phonemetable ta hi_base
include ph_tamil

phonemetable kn hi_base
include ph_kannada

phonemetable ml hi_base
include ph_malayalam

phonemetable gu hi_base
include ph_gujarati

phonemetable mr hi_base
include ph_marathi

phonemetable kok hi_base
include ph_konkani


phonemetable hu base1
include ph_hungarian

phonemetable lt base1
include ph_lithuanian


phonemetable lv base1
include ph_latvian

phonemetable pl base1
include ph_polish

phonemetable sk pl
include ph_slovak

phonemetable cs sk
include ph_czech

phonemetable hr sk
include ph_croatian

phonemetable mk hr
include ph_macedonian

phonemetable sr hr
include ph_serbian

phonemetable ru base1
include ph_russian

phonemetable bg pl
include ph_bulgarian


phonemetable it base2
include ph_italian

phonemetable la base1
include ph_latin

phonemetable es base2
include ph_spanish

phonemetable es-la es
include ph_spanish_la

phonemetable ca es
include ph_catalan

phonemetable an es
include ph_aragon

phonemetable eu base2
include ph_basque

phonemetable pt base2
include ph_pt_brazil

phonemetable pt-pt pt
include ph_portugal

phonemetable ro base2
include ph_romanian

phonemetable el base2
include ph_greek

phonemetable grc base2
include ph_greek_ancient

phonemetable sv base1
include ph_swedish

phonemetable no base1
include ph_norwegian

phonemetable is base1
include ph_icelandic

phonemetable vi base1
include ph_vietnam

phonemetable vi-hue vi
include ph_vietnam_hue

phonemetable vi-sgn vi
include ph_vietnam_sgn

phonemetable zhy base1
include ph_zh_yue

phonemetable zh base1
include ph_zh


phonemetable sw base1
include ph_swahili

phonemetable tr base2
include ph_turkish

phonemetable ku base2
include ph_kurdish

phonemetable id base2
include ph_indonesian

phonemetable sq base1
include ph_albanian

phonemetable hy base1
include ph_armenian

phonemetable da base1
include ph_danish

phonemetable ka base1
include ph_georgian

phonemetable fa base1
include ph_farsi

phonemetable ar base1
include ph_arabic

phonemetable rw base2
include ph_kinyarwanda

phonemetable prs base1
include ph_dari

phonemetable sl pl
include ph_slovenian

phonemetable gd base1
include ph_s_gaelic

phonemetable nso base1
include ph_northern-sotho

phonemetable ht fr
include ph_haitian

phonemetable az tr
include ph_azerbaijani

phonemetable ak base1
include ph_akan

phonemetable am base1
include ph_amhari

phonemetable wo base1
include ph_wolof

phonemetable dv hi_base
include ph_divehi

phonemetable te hi_base
include ph_telugu

phonemetable si hi_base
include ph_sinhala

phonemetable as bn
include ph_assamese

phonemetable or bn
include ph_oriya

phonemetable bpy bn
include ph_manipuri

phonemetable sd ur
include ph_sindhi

phonemetable tn base1
include ph_setswana

phonemetable mt base1
include ph_maltese

phonemetable bo hi
include ph_tibetan

phonemetable kk base1
include ph_kazakh

phonemetable tt base1
include ph_tatar

phonemetable ko base1
include ph_korean

phonemetable kl base1
include ph_greenlandic

phonemetable om base1
include ph_oromo

phonemetable my base1
include ph_myanmar

phonemetable gn base1
include ph_guarani

phonemetable ky base1
include ph_kyrgyz

phonemetable mi base1
include ph_maori
